def isr(n:int)->bool:
    if n%4==0:
        return True
    return False

def r(a:int,b:int)->int:
    ret = 0
    for i in range(a,b+1):
        if isr(i):
            ret+=1
    return ret

md = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

bf = 400*365+r(1,400)
d1600 = 4*bf
d1582 = d1600 - 19*365 - 5
ac = d1582 + sum(md[1:10])+4
d4713 = 4800//400*bf - r(4713,4800) - (4800-4713)*365

print(d4713 + ac)